package com.exercise.family

import com.alibaba.fastjson.JSONObject
import com.fun.utils.RString

class TestCase extends FunBase {

    static def drive = new TestCase()

    static String content = "/case"

    public JSONObject add() {
        String url = content + "/edit"
        def params = new JSONObject()
        params.put("uid", 763)
        params.put("envId", 1)
        params.put("projectList", Arrays.asList(1, 3, 5))
        params.put("serviceId", 18)
        params.put("moduleId", 24)
        params.put("apiId", 1116)
        params.put("type", "add")
        params.put("name", RString.getString(10))
        def response = getPostResponse(url, params)
        output(response)
    }

    public JSONObject update() {
        String url = content + "/edit"
        def params = new JSONObject()
        params.put("id", 1227)
        params.put("uid", 120)
        params.put("envId", 1)
        params.put("projectList", Arrays.asList(3, 5))
        params.put("serviceId", 1)
        params.put("moduleId", 1)
        params.put("apiId", 1020)
        params.put("type", "update")
        params.put("name", RString.getString(10))
        def response = getPostResponse(url, params)
        output(response)
    }

    public JSONObject copy() {
        String url = content + "/edit"
        def params = new JSONObject()
        params.put("id", 1153)
        params.put("uid", 1005)
        params.put("envId", getRandomInt(3))
        params.put("projectList", Arrays.asList(32, 324, 5))
        params.put("serviceId", 23)
        params.put("moduleId", 35)
        params.put("apiId", 2)
        params.put("type", "copy")
        params.put("name", RString.getString(10))
        def response = getPostResponse(url, params)
        output(response)
    }


    public JSONObject search() {
        String url = content + "/getcases"
        def params = new JSONObject()
        params.put("pageNum", 1)
        params.put("pageSize", 5)
        params.put("uid", 763)
        params.put("envId", 1)
//    params.put("envId", getRandomInt(3))
//    params.put("projectList", Arrays.asList(32, 324, 5))
//    params.put("serviceId", 23)
//    params.put("moduleId", 35)
//    params.put("apiId", 2)
//    params.put("name", RString.getString(10))
        def response = getGetResponse(url, params)
        output(response)
    }

    public JSONObject getRecord() {
        String url = content + "/editrecords"
        def params = new JSONObject()
        params.put("pageNum", 1)
        params.put("pageSize", 5)
        params.put("id", 1226)
        def response = getGetResponse(url, params)
        output(response)
    }
    public JSONObject getAttr() {
        String url = content + "/attribute"
        def params = new JSONObject()
        params.put("id", 1163)
        def response = getGetResponse(url, params)
        output(response)
    }

    public JSONObject getCaseDetail() {
        String url = content + "/data"
        def params = new JSONObject()
        params.put("id", 1163)
        def response = getGetResponse(url, params)
        output(response)
    }

    public static void main(String[] args) {
            drive.add()
//    drive.update()
//        drive.copy()
//        drive.search()
//        drive.getRecord()
//        drive.getAttr()
//        drive.getCaseDetail()
        testOver()
    }

}
